package snake;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class StartGame{
    public static void main(String[] args) {
        init();
    }
    public static void init(){
        JFrame jStart = new JFrame("贪吃蛇启动窗口");
        jStart.setBounds(10,10,300,80);
        jStart.setResizable(false);
        jStart.setVisible(true);
        Container container = jStart.getContentPane();
        Button one_player = new Button("one player");
        Button two_player = new Button("two player");
        one_player.setBounds(200,300,100,40);
        two_player.setBounds(200,400,100,40);
        one_player.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                JFrame jFrame = new JFrame("单兵作战");
                jFrame.setBounds(10,10,900,720);
                jFrame.setResizable(false);
                jFrame.setVisible(true);
                jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                jFrame.add(new GamePanel());
            }
        });
        two_player.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                JFrame jFrame = new JFrame("2P对战");
                jFrame.setBounds(10,10,900,720);
                jFrame.setResizable(false);
                jFrame.setVisible(true);
                jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                jFrame.add(new GamePanel_2p());
            }
        });
        JPanel jPanel = new JPanel();
        jPanel.add(one_player);
        jPanel.add(two_player);
        container.add(jPanel);
    }
}
